package br.com.unieuro.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.unieuro.dominio.Camera;
import br.com.unieuro.facade.ManterCameraFacade;

import com.google.gson.Gson;

public class FrontControllerCamera extends HttpServlet{
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
		
		String pagina = req.getParameter("pagina");
	
	if((pagina != null) && (pagina.equals("gerenciarCamera"))){
		ManterCameraFacade facade = new ManterCameraFacade();
		ArrayList<Camera> cam = facade.pesquisarCameras();
		Gson gson = new Gson();
		String json = gson.toJson(cam);
		req.getSession().setAttribute("listCam",json);

		resp.sendRedirect("jsp/gerenciarCameras.jsp");
	}
	
	
	}
}
